package com.eelpo.cmmp.uac.dao.vo;

import com.eelpo.cmmp.core.wicket.panel.paging.ISort;
import com.eelpo.cmmp.uac.dao.vo.enumed.Status;
import com.eelpo.common.util.BlankUtils;

/**
 * <pre>
 * 
 *  业务实体类型(Value Object)
 * 
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public class EntityType implements ISort {

	private static final long serialVersionUID = 1052229332212705090L;

	/**
	 * 实体类型Id
	 */
	private String id;

	/**
	 * 实体类型名称
	 */
	private String name;

	/**
	 * 实体类型代码
	 */
	private String code;

	/**
	 * 实体类型状态
	 */
	private Status status;

	/**
	 * 排序字符串
	 */
	private String sort;

	public EntityType() {

	}

	public EntityType(Status status) {
		this.status = status;
	}

	public EntityType(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public void setSort(String sort, String mode) {
		this.sort = sort.concat(" ").concat(mode);
	}

	@Override
	public boolean equals(Object obj) {
		if (BlankUtils.isBlank(obj) || !(obj instanceof EntityType))
			return false;

		if (this == obj)
			return true;

		EntityType type = (EntityType) obj;

		if (BlankUtils.isBlank(this.id) || BlankUtils.isBlank(type.getId())) {
			return false;
		}

		return this.id.equals(type.getId());
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public String toString() {
		return name;
	}
}
